#include "Widget.h"
#include "ui_Widget.h"
#include <QPainter>
#include "DialogPen.h"

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);


}

Widget::~Widget()
{
    delete ui;
}

void Widget::paintEvent(QPaintEvent *event)
{
    Q_UNUSED(event);

    QPainter painter(this);

    QRect rect(0, 0, width(), height());

    painter.setViewport(rect);  //设置 Viewport
    painter.setWindow(0, 0, 100, 50); //设置窗口大小，逻辑坐标

    painter.setPen(m_pen);
    painter.drawRect(10, 10, 80, 30) ;
}


void Widget::on_BtnSetPen_clicked()
{
    //设置pen
    bool ok = false;
    QPen pen = DialogPen::getPen(m_pen, ok);

    if(ok)
    {
        m_pen = pen;
        this->repaint();
    }

}

